home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 September / macformat-094.iso / MacFormat CD / MacFormatShareware / Internal_4_Rollover Cursor Change.ls < prev    next >
Encoding:
Text File  |  2000-07-21  |  5.3 KB  |  134 lines

  1. property spriteNum, myCursorType, myBuiltInCursor, myCursorMember, myCustomCursor, myCustomMask, mySprite, mySavedCursor
  2.  
  3. on getBehaviorDescription me
  4.   return "ROLLOVER CURSOR CHANGE" & RETURN & RETURN & "Changes the cursor when the mouse rolls over the current sprite. " & "Choose one of the pointers included with Director, or specify two 1-bit 16x16 pixel bitmap members: one to act as the pointer image, the other to define the transparent/opaque areas of the cursor." & RETURN & RETURN & "TIPS:" & RETURN & "Place a single pixel at the topRight and bottomLeft of the image itself to create what is in fact a 17x17 pixel bitmap. " & "These extra pixels will not appear in the cursor (they will be clipped) but the mask will align with them. " & "This ensures that the opaque area surrounds the cursor image correctly." & RETURN & RETURN & "Set the regPoint of the image to define the cursor's hotspot." & RETURN & RETURN & "PARAMETERS:" & RETURN & "* EITHER - Use one of Director's built-in cursors." & RETURN & RETURN & "* OR - Use your own bitmap images." & RETURN & "* Custom Image " & RETURN & "* Custom Mask" & RETURN & RETURN & "To use custom images, ensure that " & QUOTE & "1 bit bitmap" & QUOTE & " is selected as the type of cursor."
  5. end
  6.  
  7. on getBehaviorTooltip me
  8.   return "Use with graphic members." & RETURN & RETURN & "Modifies the cursor when the mouse rolls over a sprite." & RETURN & RETURN & "You can use built-in or custom images for the cursor."
  9. end
  10.  
  11. on beginSprite me
  12.   SetSpriteCursor(me)
  13. end
  14.  
  15. on endSprite me
  16.   mySprite.cursor = mySavedCursor
  17. end
  18.  
  19. on SetSpriteCursor me
  20.   mySprite = sprite(me.spriteNum)
  21.   mySavedCursor = mySprite.cursor
  22.   if voidp(myCursorType) then
  23.     mySprite.cursor = myBuiltInCursor
  24.     exit
  25.   end if
  26.   case myCursorType of
  27.     "Built-in cursor":
  28.       mySprite.cursor = myBuiltInCursor
  29.     "Cursor Member":
  30.       myCursorMember = value(myCursorMember)
  31.       cursorList = [myCursorMember.number]
  32.       mySprite.cursor = cursorList
  33.     "1 bit bitmap":
  34.       myCustomCursor = value(myCustomCursor)
  35.       cursorList = [myCustomCursor.number]
  36.       if myCustomMask <> "no mask" then
  37.         myCustomMask = value(myCustomMask)
  38.         cursorList.append(myCustomMask.number)
  39.       end if
  40.       mySprite.cursor = cursorList
  41.   end case
  42. end
  43.  
  44. on isOKToAttach me, aSpriteType, aSpriteNum
  45.   case aSpriteType of
  46.     #graphic:
  47.       return 1
  48.     #script:
  49.       return 0
  50.   end case
  51. end
  52.  
  53. on getPropertyDescriptionList me
  54.   if not (the currentSpriteNum) then
  55.     exit
  56.   end if
  57.   propertyDescriptionList = [:]
  58.   cursorTypes = []
  59.   cursorMembersList = GetCursorMembers(me)
  60.   cursorBitmapsList = GetCursorBitmaps(me)
  61.   cursorMasksList = duplicate(cursorBitmapsList)
  62.   cursorMasksList.addAt(1, "no mask")
  63.   cursorMembers = cursorMembersList.count()
  64.   bitmapCursors = cursorBitmapsList.count()
  65.   if cursorMembers then
  66.     cursorTypes.append("Cursor Member")
  67.   end if
  68.   if bitmapCursors then
  69.     cursorTypes.append("1 bit bitmap")
  70.   end if
  71.   if cursorTypes.count() then
  72.     cursorTypes.addAt(1, "Built-in cursor")
  73.     propertyDescriptionList.addProp(#myCursorType, [#comment: "CHOICE OF TYPE - Use which type of cursor?", #format: #string, #range: cursorTypes, #default: cursorTypes[1]])
  74.     propertyDescriptionList.addProp(#myBuiltInCursor, [#comment: "CHOICE OF CURSOR   -               Built-in cursor:", #format: #cursor, #default: 280])
  75.   else
  76.     return [#myBuiltInCursor: [#comment: "Use which cursor?", #format: #cursor, #default: 280]]
  77.   end if
  78.   if cursorMembers then
  79.     propertyDescriptionList.addProp(#myCursorMember, [#comment: "-             Cursor member:", #format: #member, #range: cursorMembersList, #default: cursorMembersList[1]])
  80.   end if
  81.   if bitmapCursors then
  82.     propertyDescriptionList.addProp(#myCustomCursor, [#comment: "-   1 bit bitmap (image)", #format: #bitmap, #range: cursorBitmapsList, #default: cursorBitmapsList[1]])
  83.     propertyDescriptionList.addProp(#myCustomMask, [#comment: "1 bit bitmap   (mask)", #format: #bitmap, #range: cursorMasksList, #default: cursorMasksList[1]])
  84.   end if
  85.   return propertyDescriptionList
  86. end
  87.  
  88. on GetCursorMembers me
  89.   cursorMembersList = []
  90.   maxCastLib = the number of castLibs
  91.   repeat with theCastLib = 1 to maxCastLib
  92.     maxMember = the number of castMembers of castLib theCastLib
  93.     repeat with memberNumber = 1 to maxMember
  94.       theMember = member(memberNumber, theCastLib)
  95.       if theMember.type = #cursor then
  96.         if theMember.name = EMPTY then
  97.           cursorMembersList.append(theMember)
  98.           next repeat
  99.         end if
  100.         cursorMembersList.append(theMember.name)
  101.       end if
  102.     end repeat
  103.   end repeat
  104.   return cursorMembersList
  105. end
  106.  
  107. on GetCursorBitmaps me
  108.   cursorBitmapsList = []
  109.   maxCastLib = the number of castLibs
  110.   repeat with theCastLib = 1 to maxCastLib
  111.     maxMember = the number of castMembers of castLib theCastLib
  112.     repeat with memberNumber = 1 to maxMember
  113.       theMember = member(memberNumber, theCastLib)
  114.       if theMember.type = #bitmap then
  115.         if theMember.depth > 1 then
  116.           next repeat
  117.         end if
  118.         if theMember.width > 20 then
  119.           next repeat
  120.         end if
  121.         if theMember.height > 20 then
  122.           next repeat
  123.         end if
  124.         if theMember.name = EMPTY then
  125.           cursorBitmapsList.append(theMember)
  126.           next repeat
  127.         end if
  128.         cursorBitmapsList.append(theMember.name)
  129.       end if
  130.     end repeat
  131.   end repeat
  132.   return cursorBitmapsList
  133. end
  134.